<?php

/*

Create club (club_create.pro.php)

*/
ob_start();
$rank_check = 1;
include "global.inc.php";

$clubcheck = fetch("SELECT id FROM clubs2 WHERE owner = '$userid' AND game = '$game'");
if ($clubcheck[id])
{
	die(header(error("club.php?game=$game","You can only have one club.")));
}
$check = check_length($club_name,24);
if ($check == 0)
{
	die(header(error("club_create.php?game=$game","Your club's name can only be 24 characters.")));
}
$check = check_length($club_motto,64);
if ($check == 0)
{
	die(header(error("club_create.php?game=$game","Your club's motto can only be 64 characters.")));
}
$check = check_length($description,10000);
if ($check == 0)
{
	die(header(error("club_create.php?game=$game","Your club's description can only be 10000 characters.")));
}

if ($private != 1)
{
	$private = 0;
}

if (stripspaces($club_name) == "")
{
	die(header(error("club_create.php?game=$game","Do not leave your club's name blank.")));
}
if (stripspaces($club_motto) == "")
{
	die(header(error("club_create.php?game=$game","Do not leave your club's motto blank.")));
}

if (stripspaces($description) == "")
{
	die(header(error("club_create.php?game=$game","Do not leave your club's description blank.")));
}

mysql_query("INSERT INTO clubs2 (name,motto,owner,datecreated,private,game,keywords,members) VALUES ('$club_name','$club_motto','$userid','$timestamp','$privacy','$game','$keywords','1')") or die(mysql_error());

$id = mysql_insert_id();

mysql_query("INSERT INTO club_pages2 (club,page,name,data,game) VALUES ('$id','1','home','$description','$game')") or die(mysql_error());

mysql_query("INSERT INTO club_members2 (club,user,position,game) VALUES ('$id','$userid','3','$game')") or die(mysql_error());

//header(error("club.php?game=$game&clubid=$id","Your club has been created."));

?>